WPF Diagrams represents the points at which connections can join to nodes as connection points. The pre-defined styles define connection points for each of the pre-defined node types. You will typically need to know how to specify connection point locations only if you have created a node style with a shape where the default connection point locations (the centre of each side of the bounding rectangle) are not appropriate.
Connection Points for a Custom Node Type
Connection point locations are defined by the DiagramNodeElement.ConnectionPointPositions property. This can be set through the node style. The easiest way to set this property is using a string that describes the edges and positions of the connection points.
<Setter Property="ConnectionPointPositions" Value="L 0, 0.25 R 1, 0.75 B 0.3, 1-20; 0.7, 1-20" />
The string format is as follows:
- A letter indicating the edge on which you want a connection point or points: L for left, T for top, R for right or B for bottom.
- One or more positions. Each position is a comma-separated pair of X, Y values. Multiple positions must be separated by semicolons. Positions are as fractions of the bounding box, e.g. an X coordinate of 0.5 means half way across the bounding box, optionally +/- an absolute pixel offset.
For example, the string “L 0, 0.5 R 1, 0.3; 0.9, 0.7” specifies one connection point on the Left edge at (0, 0.5) (half way down the left side) and two connection points on the Right edge, one at (1, 0.3) (30% of the way down the right edge) and one at (0.9, 0.7) (70% of the way down the right edge and indented by 10%). The string “B 0 + 100, 1 – 100” specifies a bottom connection point that is 100 pixels to the right of the left-hand edge, and 100 pixels above the bottom edge.